package com.demo.多线程;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Program: java
 * @ClassName TreadPoolDemo
 * @Author: liutao
 * @Description: 线程池
 * @Create: 2023-10-27 14:29
 * @Version 1.0
 **/

public class TreadPoolDemo {
    public static void main(String[] args) {
        // 创建线程池
        ExecutorService service = Executors.newFixedThreadPool(10);
        // 执行
        service.execute(new MyThread());
        service.execute(new MyThread());
        // 关闭连接
        service.shutdown();
    }
}

class MyThread implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 20; i++) {
            System.out.println(Thread.currentThread().getName());
        }
    }
}
